/*
 * @(#)SystemConfigInitializer.java
 *
 * Copyright 2012 by ShenY BIS, All rights reserved.
 */

package com.bis.framework.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.log4j.Logger;

import com.bis.framework.util.common.COConstants;
import com.bis.framework.util.common.SystemConfig;

/**
 * SystemConfigInitializer
 * 
 * @author BIS 2012-12-24
 */
public class SystemConfigInitializer implements ServletContextListener
{

    /**
     * Logger
     */
    private Logger logger = Logger.getLogger(getClass());

    /**
     * 监听销毁。
     */
    public void contextDestroyed(ServletContextEvent event)
    {
    }

    /**
     * 系统初始化、读取配置文件。
     */
    public void contextInitialized(ServletContextEvent event)
    {
        try
        {
            //读取配置文件信息。
            SystemConfig.onload(event.getServletContext().getResourceAsStream(COConstants.CONFIG_FILE_PATH + COConstants.COMMON_PROPERTY), false);
            logger.info("SystemConfigInitializer contextInitialized ok.");
        }
        catch (Exception ex)
        {
            logger.error("Load config fail.", ex);
        }
    }
}
